
var menuitem1 = {
    "id": "danmu",
    "title": "获取直播弹幕",
    "contexts": ["all"]
}

chrome.runtime.onInstalled.addListener(()=>{
    chrome.contextMenus.create(menuitem1)
})
chrome.contextMenus.onClicked.addListener((clickData) => {
    const itemID = clickData.menuItemId
    const pageUrl = clickData.pageUrl
    chrome.windows.getCurrent((window)=>{
        console.log(window)
        chrome.windows.update(window.id,{
            width:500,
            height:800,
            top:0,
            left:0,
            focused:true,
            state:"normal"},e=>{
            console.log('调整窗口成功')

        })
    })
    // chrome.tabs.executeScript(null,{file:"js/stop.js"})

    if(pageUrl.indexOf('kuaishou')>0){
        chrome.tabs.executeScript(null,{file:"js/stopKS.js"})
        chrome.tabs.insertCSS(null, { file: "css/kuaishou.css" })
    }else if(pageUrl.indexOf('douyin')>0){
        chrome.tabs.executeScript(null,{file:"js/stopDY.js"})
        chrome.tabs.insertCSS(null, { file: "css/douyin.css" })
    }else if(pageUrl.indexOf('ixigua')>0){
        chrome.tabs.insertCSS(null, { file: "css/xigua.css" })
    }else if(pageUrl.indexOf('taobao')>0){
        chrome.tabs.executeScript(null,{file:"js/stopTB.js"})
        chrome.tabs.insertCSS(null, { file: "css/taobao.css" })
    }else if(pageUrl.indexOf('weixin')>0){
        chrome.tabs.executeScript(null,{file:"js/stopWX.js"})
        chrome.tabs.insertCSS(null, { file: "css/weixin.css" })
    }
    
})